package com.platform.server.valid;


import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;


public class IrregularValImpl implements ConstraintValidator<IrregularValValid, Integer> {

    int[] irregularVal;
    
    @Override
    public void initialize(IrregularValValid constraintAnnotation) {
        
        this.irregularVal = constraintAnnotation.irregularVal();
    }

    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext context) {

        for(int val : irregularVal){
            
            if(val == value){
                
                return true;
            }
        }
        return false;
    }

}
